USE [LAFDC]
GO
/****** Object:  StoredProcedure [dbo].[Listage_de_reference]    Script Date: 11/23/2009 22:59:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[Listage_de_reference]
	-- Add the parameters for the stored procedure here
	@ad as varchar(3)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
		select upper(a.prev_id) as 'n° CP', upper(p.nom) as 'Nom', p.prenom as 'Prenom',
				case a.retenu when 'OUI' then '1' end as 'PRELEVE',
				case a.retenu when 'NON' then '1' end as  'NON PRELEVE',
				upper(a.section) as 'Section'
		 from adherent a join personne p on a.prev_id = p.prev_id
		 where ad = @ad
		   and sfam !='Enfant' and sfam !='conjoint(e)'
		 order by a.section, p.nom
END
